package com.psytech.app.task.web_ui.client;

import java.util.Date;

import com.psytech.app.task.web_ui.shared.UiTask;
import com.smartgwt.client.widgets.grid.ListGridRecord;

public class TaskRecord extends ListGridRecord {

	UiTask uiTask;

	public TaskRecord() {

	}

	public TaskRecord(final UiTask task) {
		this.uiTask = task;
		this.setAttribute("name", task.getName());
		this.setAttribute("creatorUid", task.getCreator().getUid());
		this.setAttribute("creator", task.getCreator().getLogin());
		this.setAttribute("description", task.getDescription());
		this.setAttribute("priority", task.getPriority().toString());
		this.setAttribute("status", task.getStatus().toString());
		this.setAttribute("expectedEndDate", task.getExpectedEndDate());
		this.setAttribute("expectedStartDate", task.getExpectedStartDate());
		this.setAttribute("uid", task.getUid());
		if (task.getAffectedUsers().size() != 0) {
			this.setAttribute("affectedUserUid", task.getAffectedUsers().get(0).getUid());
			this.setAttribute("affectedUser", task.getAffectedUsers().get(0).getLogin());
		}
	}

	public UiTask getInnerUiTask() {
		return this.uiTask;
	}

	public String getCreatorUid() {
		return this.getAttributeAsString("creatorUid");
	}

	public void setCreatorUid(final String creatorName) {
		this.setAttribute("creatorUid", creatorName);
	}

	public String getDescription() {
		return this.getAttributeAsString("description");
	}

	public void setDescription(final String description) {
		this.setAttribute("descriptor", description);
	}

	public String getName() {
		return this.getAttributeAsString("name");
	}

	public void setName(final String name) {
		this.setAttribute("name", name);
	}

	public String getPriority() {
		return this.getAttributeAsString("priority");
	}

	public void setPriority(final String priority) {
		this.setAttribute("priority", priority);
	}

	public Date getExpectedEndDate() {
		return this.getAttributeAsDate("expectedEndDate");
	}

	public void setExpectedEndDate(final Date expectedEndDate) {
		this.setAttribute("expectedEndDate", expectedEndDate);
	}

	public Date getExpectedStartDate() {
		return this.getAttributeAsDate("expectedStartDate");
	}

	public void setExpectedStartDate(final Date expectedStartDate) {
		this.setAttribute("expectedStartDate", expectedStartDate);
	}

	public String getStatus() {
		return this.getAttributeAsString("status");
	}

	public void setStatus(final String status) {
		this.setAttribute("status", status);
	}

	public String getAffectedUserUid() {
		return this.getAttributeAsString("affectedUserUid");
	}

	public void setAffectedUserUid(final String affectedUserUid) {
		this.setAttribute("affectedUserUid", affectedUserUid);
	}

}
